
import json
import os
import pickle
import lightgbm as lgb

def fix_file_path_name(file_path_name):
    current_path = os.path.dirname(__file__)
    file_path_name = file_path_name.replace("./", current_path + "/")
    file_path_name = file_path_name.replace("\\\\", "/")
    return file_path_name


    with open(path, "r") as f:
        test_params = json.load(f)
    test_params = json.loads(test_params)


# model转成pkl
file_path_name3 = './model/old_v1_20240714.model'
current_path = os.path.dirname(__file__)
file_path_name3 = file_path_name3.replace("./", current_path + "/")
lgbm_model = lgb.Booster(model_file=file_path_name3)
# 将模型保存为 text.pkl
pkl_path = file_path_name3.replace(".model", ".pkl")
with open(pkl_path, 'wb') as f:
    pickle.dump(lgbm_model, f)
print('成功')

# params = './params.json'
# params = fix_file_path_name(params)
# with open(params, 'rb') as f:
#     params = json.load(f)
# # params = json.loads(params)
# print("成功读取：params")
# print(params)


# params_old = './params_old.json'
# params_old = fix_file_path_name(params_old)
# with open(params_old, 'rb') as f:
#     params_old = json.load(f)
# # params_old = json.loads(params_old)
# print("成功读取：params_old")
# # print(params_old)
